package com.example.qingyiapp.service.netutils;

import android.content.Context;

import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * @author ：created by 申德丰
 * Create Date ：2019/9/15 10:10
 * Package_Name : QingYiApp
 */
public class Retrofitnetutlis {

    private static Retrofitnetutlis retrofitnetutlis;

    private static Retrofit retrofit;

    private  String url;
    private Context context;

    private Retrofitnetutlis( Context context,String url) {
        this.url = url;
        this.context = context;
        init();
    }

    public static Retrofitnetutlis getInstance(Context context, String url) {
        if (retrofitnetutlis == null) {
            retrofitnetutlis = new Retrofitnetutlis(context,url);


        }
        return retrofitnetutlis;
    }

    private void init() {
        retrofit = new Retrofit.Builder().baseUrl(url).addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .build();//RxJava
    }

    public IRetrofit getiretrofit(){


        return retrofit.create(IRetrofit.class);
    }

}
